wikicompfandomcom-20200214-history
Help:Infobox Template Tutorial
Infoboxes can be intimidating at a first glance. There are lines of code that don't explain how they're used. This tutorial will make Infoboxes more friendly and easy to use. Does an Infobox template I can use already exist? When considering the addition of an Infobox to your page, it helps to know what information you want to present inside the Infobox. Based on the template you use, you will get different Infoboxes that all hold different information. The best part about Templates is the conditional sections. These work like the contents box on any page, they only appear when certain conditions are met. In the case of templates, these conditional sections only display when they are given information to present. For example, if Weight were a conditional, I would tell the template that Weight = 120lbs in order to have the Weight section display in the Infobox. Without the 120lbs, Weight would be blank and would not show up in the Infobox. The help expedite your search for a template, here is a list of some templates, what's in them, and where they're being used. Existing templates These templates are listed with the information they are designed to display in order. They also have links to pages currently using each template. Items marked with a hyphen are conditional and only display if given information. * Contains: tittle, -image and image caption, artist, released, recorded, length, label, producer. Pages using this template: * Contains: title, -image and image caption, author, illustrator, published on, published by, previous book, next book. Pages using this template: * Contains: title, -image and image caption, position, age, status, height, weight. Pages using this template: * Contains: title,season, number, -image and image caption, air date, written by, directed by, previous episode, next episode. Pages using this template: * Contains: title, -image and image caption, participants, date, location. Pages using this template: * Contains: title, -image and image caption, type, effects, source, cost to buy, cost to sell Pages using this template: * Contains: title, -image and image caption, birth date, -birth place, death date, -death place, nationality, -spouse, -influenced, -influenced by, -known for. Pages using this template: Kenneth Burke * Contains: title, -image and image caption, birth date, death date, nationality, -spouse, -influenced by, -influenced, -notable ideas. Pages using this template: Socrates, Plato * Contains: title, -image and image caption, -map and map caption, type, level, location, inhabitants. Pages using this template: * Contains: title, -image and image caption, start, end, prerequisites, level, location, rewards, previous quest, next quest. Pages using this template: How to modify existing templates without changing other peoples Infoboxes Let's say that one of the Infoboxes listed above, fits everything except one or two sections you want to add. Well it's not as hard as it looks. All templates follow the same source code. *|- *! Birth date *| } And *|- * } | *! Notable Ideas * } *| }} These are the only parts of the code that you will have to deal with to add a section to a preexisting template. The first is an independent section. As such, it will display even if it is left blank. The second is the conditional, that only appears when we give it information. The conditional will be our best friend while modifying previous templates because we can add the section we need without it showing up on someone else's page. Let's see how this works. The very basic Infobox without a template looks like this: Notice how first, second, and third appear under some attribute. There is another tittle, other attributes but nothing is under it. That's because I did not specify any information relating to the Infobox. This is a plain empty Infobox. Now let's add to it. * This new information will cause the box to present this now: As we can see, fourth and fifth are both conditionals, leave them black or completely omit them, and you won't see them. Now the more complicated and involved part. Remember that conditional code at the top of this section? That's how we need to add sections to preexisting templates. When we go to the page for a template with the links above, we see that it is editable. All of them will have more code than the two I placed above, but they won't matter to us. Just don't delete them. Let's say we want to add a section to our philosopher template. Let's call it Spouse. To add our new section to the code for philosopher we have to place it between two different pieces of information or at the end. You can't put spouse in the middle of the box if it come at the end of the code, so know where you want it. When you find where you want to put it, in this case lets put it after nationality and before influenced by. In the code we will find this before we change anything: *|- *! Nationality *| } * *|- * } | *! Influenced By * } *| }} To add spouse simply splice in a conditional statement such as this: *|- * } | *! Spouse * } *| }} Between nationality and influenced by. We will then have this: *|- *! Nationality *| } * *|- * } | *! Spouse * } *| }} * *|- * } | *! Influenced By * } *| }} Then you're all set. And when we create an Infobox with the philosopher template, if the spouse conditional is not declared, it won't show up, then you can use it with your box, and not affect anyone else's. Now how about we learn a bit about the code. Let's look at nationality first. Notice how it's preceded by an !. In wiki code, this basically says that we're starting a new line for the Infobox called 'Nationality.' The second line, } says that if the variable 'nationality' is not given a string value(Greek, American, European, or any sentence or word is a string value) to simply output 'Unknown.' Now let's look at the conditional, obviously different from the expected values like nationality. } | Is exactly what it looks like, an if statement. If this, do that. In this case, the code says if |spouse = (any string value) while declaring an Infobox under the philosopher template, then display the Spouse line with its declared value. The second line, like the first of the nationality, declares a new section of the Infobox. Lastly the third line states like the second of the nationality section, except it doesn't declare a filler string value for Spouse. Creating a new Infobox template To make an new Infobox template, first try to give it a name relating to what information it can hold. Then simply declare a new Infobox, such as . When we try to do that, the Infobox will give you a red message because it will not understand what to do with the template dogbreed, because it does not exist. Now let's walk through making our own dogbreed Infobox template. When you click on the red link made by the unknown template, it will direct you to a new page for the new template. First click edit on that page, it will be entirely blank and the first thing to type is this: * }} | * class="wikia-infobox-image" colspan="2" *| }} * *|- * } | * class="wikia-infobox-caption" colspan="2" } *| }} This declares an Infobox, with a title and an optional image with a caption. Now the easy part we've seen before. To add sections, simply use the expected format or the conditional format from the above section. When you've added all the sections you want, there is one last price of coding to Finnish it all off: *|- style="font-size:0; line-height:0;" *! style="width:50%; padding:0" | *! style="width:50%; padding:0" | * *|} * This simply tell the Infobox about its font and design and where it ends. Only one thing left, you're almost there. Let's say we want to add a section title to a group of common buts of info, will its as easy as splicing this in before the group: *|- *! colspan="2" | Vital statistics